import java.util.ArrayList;

/**
 * @author gaopeng
 * @date 2019/12/9 9:55 下午
 */
public class Deep implements Cloneable {
    private ArrayList<String> list = new ArrayList<>(2);

    public ArrayList<String> getList() {
        return list;
    }

    public void setList(ArrayList<String> list) {
        this.list = list;
    }

    @Override
    protected Deep clone() throws CloneNotSupportedException {
        Deep deep = (Deep) super.clone();
        deep.setList((ArrayList<String>) this.list.clone());
        return deep;
    }

    public static void main(String[] args) throws CloneNotSupportedException {
        Deep deep = new Deep();
        deep.getList().add("zhangsan");
        Deep clone = deep.clone();
        clone.getList().add("lisi");
        deep.getList().forEach(System.out::println);
    }
}
